package com.cn.wanxi.service.impl;

import com.cn.wanxi.dao.ProductDao;
import com.cn.wanxi.dao.impl.ProductImpl;
import com.cn.wanxi.model.PageModel;
import com.cn.wanxi.model.ProductModel;
import com.cn.wanxi.service.IProductService;

import java.util.List;

/**
 * 服务逻辑层,调用数据层
 */
public class ProductServiceImpl implements IProductService {
    @Override
    public int add(ProductModel productModel) {
        ProductDao productDao = new ProductImpl();

        return productDao.add(productModel);
    }

    @Override
    public List<ProductModel> findAll(PageModel pageModel) {
        ProductDao productDao = new ProductImpl();

        return productDao.findAll(pageModel);
    }

    @Override
    public ProductModel findById(Integer id) {
        ProductDao productDao = new ProductImpl();
        ProductModel productModel = productDao.findById(id);
        CuisineServiceImpl cuisineService = new CuisineServiceImpl();
        productModel.setList(cuisineService.findAll());
        return productModel;
    }

    @Override
    public int del(int id) {
        ProductDao productDao = new ProductImpl();
        return productDao.del(id);
    }
    @Override
    public int getCount(){
        ProductDao productDao = new ProductImpl();
        return productDao.getCount();
    }

}
